/*
package com.thread.threadfirst.rabbitMQPublisher.consumer;

import com.alibaba.fastjson.JSON;
import com.rabbitmq.client.Channel;
import com.thread.threadfirst.rabbitMQPublisher.constant.AMQPConstant;
import com.thread.threadfirst.rabbitMQPublisher.vo.RegisterVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

import java.awt.image.renderable.ContextualRenderedImageFactory;
import java.io.IOException;
import java.util.Map;

@Component
@Slf4j  //lombok依赖中的
public class ConsumerFirst {

    //    @RabbitHandler
    @RabbitListener(queues = AMQPConstant.QUEUE_FIRST, containerFactory = "multiListenerContainer")
    //注意：这里queue的名字是return new Queue(AMQPConstant.DEFAULT_QUEUE);这行设定的。
    public void listener(Message vo, Channel channel, @Header(name = "amqp_deliveryTag") long deliveryTag,
                         @Header(name = "amqp_redelivered") boolean redelivered, @Headers Map<String, String> headers) {
        String message = vo.toString();
        log.info("vo : {}", message);
        try {
            String messageContent = new String(vo.getBody(), "utf-8");
//            JSONObject jsonObject = JSONObject.fromObject(messageContent);
//            RegisterVO registerVO = (RegisterVO) JSONObject.toBean(jsonObject, RegisterVO.class);
            RegisterVO registerVO = JSON.parseObject(messageContent, RegisterVO.class);
            Long tag=new Long( headers.get(AmqpHeaders.DELIVERY_TAG) );  //从headers中直接获取属性
            log.info("singleListenerContainer receive message:{},headers:{},correlationId:{}", registerVO.toString(), headers, tag);
            log.info("处理业务");
            channel.basicAck(deliveryTag, true);
        } catch (Exception e) {
            log.error("consumer confirm error! {}", e.getMessage());
            try {
                channel.basicReject(deliveryTag, !redelivered); //redelivered:消息是否被重发 为false
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }
}
*/
